package com.copa.l344;

import java.util.Arrays;

/**
 * @author copa
 * @createDate 2022-06-29 12:35
 * @function
 */
public class Test2 {

    public void reverseString(char[] s) {
        int left = 0;
        int right = s.length - 1;
        reverseChar(s, left, right);
    }

    private void reverseChar(char[] s, int left, int right) {
        if (left <= right) {
            int tempLeft = left;
            int tempRight = right;
            reverseChar(s, ++left, --right);
            char temp = s[tempLeft];
            s[tempLeft] = s[tempRight];
            s[tempRight] = temp;
        }
    }

    public static void main(String[] args) {
        char[] s = {'H','a','n','n','a','h'};
        new Test2().reverseString(s);
        System.out.println(Arrays.toString(s));
    }
}
